﻿Public Class frmPartnerDetail

#Region "Method"

#Region "Overrides"

    ''' <summary>
    ''' Sub đưa dữ liệu hiển thị trên control
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 24/10/2010</remarks>
    Protected Overrides Sub BindingControl()
        With BusinessObject.dsFMS.Partner
            txtName.DataBindings.Add("Text", bsFMS, .PartnerNameColumn.ColumnName)
            txtEmail.DataBindings.Add("Text", bsFMS, .PartnerEmailColumn.ColumnName)
            txtPhone.DataBindings.Add("Text", bsFMS, .PartnerPhoneColumn.ColumnName)
            txtWebsite.DataBindings.Add("Text", bsFMS, .PartnerWebsiteColumn.ColumnName)
            txtAddress.DataBindings.Add("Text", bsFMS, .PartnerAddressColumn.ColumnName)
            txtDescription.DataBindings.Add("Text", bsFMS, .PartnerDescriptionColumn.ColumnName)
            If ActionMode <> clscommon.ActionMode.Add Then
                LoadRepresentativeList()
            End If
        End With
    End Sub

    ''' <summary>
    ''' Sub xóa binding dữ liệu trên control
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 24/10/2010</remarks>
    Protected Overrides Sub ClearDataBingding()
        With Me
            .txtName.DataBindings.Clear()
            .txtEmail.DataBindings.Clear()
            .txtPhone.DataBindings.Clear()
            .txtWebsite.DataBindings.Clear()
            .txtAddress.DataBindings.Clear()
            .txtDescription.DataBindings.Clear()
        End With
    End Sub

    ''' <summary>
    ''' Sub set thuộc tính cho các control là read only hay không
    ''' </summary>
    ''' <param name="isReadOnly">Ở chế độ read only thì đặt là true và ngược lại</param>
    ''' <remarks>Nguyễn Huy Thường added on 24/10/2010</remarks>
    Protected Overrides Sub SetControlEditable(ByVal isReadOnly As Boolean)
        MyBase.SetControlEditable(isReadOnly)
        With Me
            .txtName.ReadOnly = isReadOnly
            .txtEmail.ReadOnly = isReadOnly
            .txtPhone.ReadOnly = isReadOnly
            .txtWebsite.ReadOnly = isReadOnly
            .txtAddress.ReadOnly = isReadOnly
            .txtDescription.ReadOnly = isReadOnly
            If ActionMode = clscommon.ActionMode.Add Then
                BusinessObject.dsFMS.Representative.Clear()
            End If
        End With
    End Sub

    ''' <summary>
    ''' Sub xác định vị trí của bản ghi hiện thời và load lại dữ liệu
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 24/10/2010</remarks>
    Protected Overrides Sub RefreshData()
        MyBase.RefreshData()
        If Not IsNothing(bsFMS.Current) And ActionMode <> clscommon.ActionMode.Add Then
            LoadRepresentativeList()
        End If
    End Sub
#End Region

    ''' <summary>
    ''' Sub đưa danh sách những người đại diện cho đối tác lên grdRepresentiveList
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 26/06/2012</remarks>
    Private Sub LoadRepresentativeList()
        With BusinessObject
            .dsFMS.Representative.Clear()
            .GetDataByValue(.dsFMS.Representative.TableName, .dsFMS.Partner.PartnerIDColumn.ColumnName, bsFMS.Current(.dsFMS.Partner.PartnerIDColumn.ColumnName))
        End With
        With Me
            .grdRepresentativeList.DataSource = BusinessObject.dsFMS
            .grdRepresentativeList.DataMember = BusinessObject.dsFMS.Representative.TableName
        End With
    End Sub
#End Region
End Class
